home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / NDX_SCAN.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-27  |  3KB  |  89 lines

  1. Program Ndx_Scan;
  2. {------------------------------------------------------------------------------
  3.                           DBase File Index Analyze
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        24 July 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program can be used to analyze a .NDX file.  Note it uses the
  14.        GSOB_NDX unit directly, showing the unit works independent of the
  15.        dBase engine.   This example only works on character keys.  Numeric
  16.        or date keys are not displayed.
  17.  
  18. -------------------------------------------------------------------------------}
  19.  
  20. uses Crt, Dos, GSOB_NDX;
  21.  
  22. var
  23.    RPag      : LongInt;
  24.    i,j,k,v   : integer;
  25.    rl        : integer;
  26.    ct        : integer;
  27.    recnode,
  28.    Less_Than : boolean;
  29.    WorkNode  : GSP_InxNode;
  30.    Next_Blk  : Longint;
  31.    Ndx_F     : GSO_IndexFile;
  32.    FName     : string;
  33.  
  34. begin
  35.    Clrscr;
  36.    Write('Enter Index File (without .NDX extension): ');
  37.    Readln(FName);
  38.    NDX_F.Init(FNAME);
  39.    with NDX_F do
  40.    begin
  41.    Next_Blk := Ndx_NextBlock;
  42.    writeln('--------------------------------------------------');
  43.    writeln('File Name = ',dfFileName);
  44.    writeln('Key Expression = ',ixKey_Form);
  45.    writeln('Key Length = ',Key_Lgth,
  46.                 '   Maximum Keys/Block = ',Max_Keys);
  47.    writeln('Root =',Ndx_Root:5,'   Next Block Available:',Next_Blk:5);
  48.    tbLink^.FreeAll;
  49.    WorkNode := tbLink^.FetchTop;
  50.    writeln('Data records are at Level ',tbLink^.Count,
  51.                 ' in the hierarchy.');
  52.    window(1,7,80,25);
  53.    RPag := Ndx_Root;
  54.    while (RPag < Next_Blk) and (RPag <> 0) do
  55.    begin
  56.       WorkNode := tbLink^.NodeGet(RPag);
  57.       k := WorkNode^.ItemCount;
  58.       System.write(RPag:5,'  [',k:2,']');
  59.       CurrElmt :=  tbLink^.Elements[0];
  60.       recnode := not WorkNode^.nonLeaf;
  61.       v := 1;
  62.       i := 1;
  63.       while (i <= k) do
  64.       begin
  65.          CurrElmt :=  tbLink^.Elements[i-1];
  66.          with CurrElmt^ do
  67.          begin
  68.             System.write('':v,Block_Ax:5);
  69.             v := 12;
  70.             if (i = k) and not recnode then System.write('    0 - empty')
  71.             else
  72.                begin
  73.                   System.write(Recrd_Ax:5,' ');
  74.                   if Ndx_Hdr.Data_Typ = 0 then
  75.                      for j := 1 to Key_Lgth do
  76.                         System.write(Char_Fld[j]);
  77.                end;
  78.          end;
  79.          System.WRITELN;
  80.          inc(i);
  81.       end;
  82.       system.writeln;
  83.       System.Write('Enter Block (0 to Quit): ');
  84.       Readln(RPag);
  85.       tbLink^.FreeAll;
  86.    end;
  87.    end;
  88. end.
  89.